package com.bite.book.config;

import com.bite.book.interceptor.LoginInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Slf4j
//进行注册拦截器；
//进行将这个方法交由spring进行管理；
@Configuration
public class WebConfig implements WebMvcConfigurer {
    //进行注入这个拦截器对象；
    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    //进行添加拦截器；
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/book/**") ;//进行拦截所有的请求；
        //此处只有进行拦截book;

    }
}
